﻿using System;
using System.Windows.Forms;
using System.Drawing;

namespace eCompany
{
    public class Tools
    {
        public static DialogResult InputBox(string title, string promptText, ref string value)
        {
          Form form = new Form();
          Label label = new Label();
          TextBox textBox = new TextBox();
          Button buttonOk = new Button();
          Button buttonCancel = new Button();

          form.Text = title;
          label.Text = promptText;
          textBox.Text = value;

          buttonOk.Text = "OK";
          buttonCancel.Text = "Cancel";
          buttonOk.DialogResult = DialogResult.OK;
          buttonCancel.DialogResult = DialogResult.Cancel;

          label.SetBounds(9, 20, 372, 13);
          textBox.SetBounds(12, 36, 372, 20);
          buttonOk.SetBounds(228, 72, 75, 23);
          buttonCancel.SetBounds(309, 72, 75, 23);

          label.AutoSize = true;
          textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
          buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
          buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

          form.ClientSize = new Size(396, 107);
          form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
          form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
          form.FormBorderStyle = FormBorderStyle.FixedDialog;
          form.StartPosition = FormStartPosition.CenterScreen;
          form.MinimizeBox = false;
          form.MaximizeBox = false;
          form.AcceptButton = buttonOk;
          form.CancelButton = buttonCancel;

          DialogResult dialogResult = form.ShowDialog();
          value = textBox.Text;
          return dialogResult;
        }
        public static DialogResult InputBox(string title, string promptText1, string promptText2, ref string value1, ref string value2)
        {
            Form form = new Form();
            Label label1 = new Label();
            TextBox textBox1 = new TextBox();
            Label label2 = new Label();
            TextBox textBox2 = new TextBox();
            Button buttonOk = new Button();
            Button buttonCancel = new Button();

            form.Text = title;
            label1.Text = promptText1;
            textBox1.Text = value1;
            label2.Text = promptText2;
            textBox2.Text = value2;

            buttonOk.Text = "OK";
            buttonCancel.Text = "Cancel";
            buttonOk.DialogResult = DialogResult.OK;
            buttonCancel.DialogResult = DialogResult.Cancel;

            label1.SetBounds(9, 20, 372, 13);
            textBox1.SetBounds(12, 36, 372, 20);
            label2.SetBounds(9, 72, 372, 13);
            textBox2.SetBounds(12, 88, 372, 20);
            buttonOk.SetBounds(228, 120, 75, 23);
            buttonCancel.SetBounds(309, 120, 75, 23);

            label1.AutoSize = true;
            textBox1.Anchor = textBox1.Anchor | AnchorStyles.Right;
            label2.AutoSize = true;
            textBox2.Anchor = textBox2.Anchor | AnchorStyles.Right;
            buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
            buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;

            form.ClientSize = new Size(396, 160);
            form.Controls.AddRange(new Control[] { label1, textBox1, label2, textBox2, buttonOk, buttonCancel });
            form.ClientSize = new Size(Math.Max(300, label1.Right + 10), form.ClientSize.Height);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.MinimizeBox = false;
            form.MaximizeBox = false;
            form.AcceptButton = buttonOk;
            form.CancelButton = buttonCancel;

            DialogResult dialogResult = form.ShowDialog();
            value1 = textBox1.Text;
            value2 = textBox2.Text;
            return dialogResult;
        }
        public static Image GetCompanyTypeImage(eCompany.eObj.company_type_enum company_type)
        {
            return (Image)pics.ResourceManager.GetObject(company_type.ToString());
                //[company_type.ToString()];
        }
        public static Image GetRawTypeImage(eCompany.eObj.material_type_enum raw_type)
        {
            return (Image)pics.ResourceManager.GetObject(raw_type.ToString().ToLower());
        }
        public static Image GetCurrencyImage(string sCurrency)
        {
            return (Image)pics.ResourceManager.GetObject(sCurrency);
        }
        public static Image GetCustomLevelImage(int level)
        {
            switch (level)
            {
                case 0:
                    return pics.q0;
                case 1:
                    return pics.q1;
                case 2:
                    return pics.q2;
                case 3:
                    return pics.q3;
                case 4:
                    return pics.q4;
                default:
                    return pics.q5;
            }
        }
    }
}